import numpy as np
import pandas as pd
# s = pd.Series(data , index=index)
s = pd.Series(np.random.randn(5) , index=["a" , "b" , "c" , "d" , "e"])
# print(s)
# print(s.index)
# print(pd.Series(np.random.randn(5)))
d= {"b":1 , "a":0 , "c":2}
# print(pd.Series(d))

d1 = {"a":1 , "b":0 , "c":2}
# print(pd.Series(d1 , index=["b","a","c", "d"]))
# print(pd.Series(5.0 , index=["a" , "b" , "c" , "d" , "e"]))
# print(s.iloc[0])
# print(s.iloc[:3])

# print(s[s>s.median()])

# print(s.iloc[[4,3,1]])

# print(np.exp(s))
# print(s.dtype)
# print(s.array)
d ={
    "one": pd.Series([1, 2, 3], index=["a", "b", "c"]) ,
    "two": pd.Series([1, 2, 3 ,4], index=["a", "b", "c" , "d"]) ,
}
directdf = pd.DataFrame(d)
# print(directdf)

# print(pd.DataFrame(d , index=["d" , "b" , "a"]))

# print(pd.DataFrame(d , index=["d" , "b" , "a"] , columns=["two" , "three"]))
# print(directdf.index)
# print(directdf.columns)
d1 = {
    "one":[1.0,2.0 , 3.0 , 4.0] ,
    "two":[4.0 , 3.0 , 2.0 , 1.0]
}
# print(pd.DataFrame(d1))
# print(pd.DataFrame(d1 , index=["a", "b" , "c" , "d"]))
data = np.zeros((2,) , dtype=[("A" , "i4") , ("B" , "f4") , ("C" , "a10")])
data[:] = [(1,2.0 , "hello") , (2,3.0,"world")]
# print(pd.DataFrame(data))
# print(pd.DataFrame(data , index=["first" , "second"]))

# print(pd.DataFrame(data , columns=["C" , "A" , "B"]))

data2 = [{"a":1 , "b":2} , {"a":5 , "b":10 , "c":20}]
# print(pd.DataFrame(data2))
# print(pd.DataFrame(data2 , index=["first" , "second"] , columns=["a" , "b"]))

ser = pd.Series(range(3) , index=list("abc") , name="ser")
# print(pd.DataFrame(ser))

from collections import  namedtuple
Point=namedtuple("Point"  , "x y")
# print(pd.DataFrame([Point(0,0) , Point(0,3) , Point(2,3)]))
Point3D = namedtuple("Point3D" , "x y z")
# print(pd.DataFrame([ Point3D(0,3,5) , Point3D(2,3,5) , Point(2,3)]))
from dataclasses import make_dataclass
Point1 = make_dataclass("Point1" , [("x" , int ),("y",int)])
# print(pd.DataFrame([Point1(0,0) , Point1(0,1) , Point1(3,4) ]))
# print(pd.DataFrame.from_dict(dict([("A" , [1,2,3]) , ("B" , [4,5,6])])))
# print(pd.DataFrame.from_dict(
#     dict([("A" , [1,2,3]) , ("B",[4,5,6]) ]),
#     orient="index" ,
#     columns=["one" , "two" , "three"]
# ))
np.random.randn(3,12)

